/************** init.html **************/


function query_reward(page) {
	sys_loading();
	var parm = $('#queryRewardForm').serialize() + (page != null ? ('&page=' + page) : '');
	var url = create_url('reward-query');
	sys_record_parm('reward',parm);
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_loading_close();
			$('#rewardResultList').html(result);
		}
	});
}

function shield_reward(code) {
	$.Zebra_Dialog('确认要屏蔽吗？',{
	'type': 'question','title': '警告' ,'buttons':[
       {caption:'屏蔽',callback:function() {
    	   var url = create_url('reward-shield');
    	aidExecuteApply_apply(code, url);
		}},
    {caption:'取消',callback:function(){}
	}]
	});
}

function unshield_reward(code) {
	$.Zebra_Dialog('确认要解除吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
       {caption:'解除',callback:function() {
    	   var url = create_url('reward-unshield');
    	aidExecuteApply_apply(code, url);
		}},
       {caption:'取消',callback:function(){}
	}]
	});
}
function delete_reward(code) {
	$.Zebra_Dialog('确认要撤销奖惩信息吗？',{
	'type': 'question',
	'title': '警告' ,
	'buttons':[
	           {caption:'确认',callback:function() {
					var url = create_url('reward-delete');
					var parm = {'code':code};
					sys_submiting();
					$.ajax({type:'POST', url:url, data:parm,
						success: function(result) {
							sys_submiting_close();
							query_reward();
					}
					})}},
	           {caption:'取消',callback:function(){}}
				]
	});
}

function save_reward() {
	  //验证输入框是否有未填写的
	var ok = false;
	$('#editRewardForm').find('textarea').each(function(e) {
		if ('' == this.value || undefined == this.value) {
			$(this).css('border-color','red');
			ok = false;
		} else {
			ok = true;
		}
	});
	if (!ok) {
		sys_msg('不能有空值,如果不需要保存的请删除在保存！');
		return false;
	}
	var parm = $('#editRewardForm').serialize();
	var url = create_url('reward-save');
	sys_submiting();
	$.ajax({type:'POST', url:url, data:parm,
		success: function(result) {
			sys_submiting_close();
			if (result == 'success') {
				sys_load_handle('reward');
			} else if (result == 'exists') {
				sys_msg('还没选员工姓名呢!');
			} else {
				sys_msg('操作失败!');
			}
		}
	});
}
